// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
#include <stdio.h>

#include "gtest/gtest.h"


int foo(int a, int b) {
  if (a == 0 || b == 0) {
    throw "dot't do that.";
  }
  int c = a % b;
  if (c == 0) 
      return b;
  return foo(b, c);
}

TEST(FooTest, HandleNoneZeroInput) {
    EXPECT_EQ(2, foo(4, 10));
    EXPECT_EQ(6, foo(30, 18));
}
TEST(BarTest, AllEqualTest) {
    for (int i = 0, j = 1; i < 5 && j < 6; ++i, ++j) {
        EXPECT_EQ(i + 1, j) << "error index: " << i;
    }
}

TEST(StringCmpTest, Demo)
{
    char* pszCoderZh = "CoderZh";
    wchar_t* wszCoderZh = L"CoderZh";
    std::string strCoderZh = "CoderZh";
    std::wstring wstrCoderZh = L"CoderZh";

    EXPECT_STREQ("CoderZh", pszCoderZh);
    EXPECT_STREQ(L"CoderZh", wszCoderZh);

    EXPECT_STRNE("CnBlogs", pszCoderZh);
    EXPECT_STRNE(L"CnBlogs", wszCoderZh);

    EXPECT_STRCASEEQ("coderzh", pszCoderZh);

    EXPECT_STREQ("CoderZh", strCoderZh.c_str());
    EXPECT_STREQ(L"CoderZh", wstrCoderZh.c_str());
}

TEST(ExplicitTest, Demo)
{
    SUCCEED();
}

TEST(FooTest, HandleZeroInput)
{
    EXPECT_ANY_THROW(foo(10, 0));
    EXPECT_THROW(foo(0, 5), char*);
}


int main(int argc, char** argv) {
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
